<?php

namespace App\Listeners;

use App\Events\UsersAmountEvent;
use App\Service\users\AccountRecordService;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;

class UsersAmountSave
{

    public function handle(UsersAmountEvent $event): void
    {
        try {
            AccountRecordService::instance()->createAmountRecord(
                $event->data['uid'],
                $event->data['num'],
                $event->data['credit_type'],
                $event->data['type'],
                $event->data['table_id'],
                $event->data['remark'],
                $event->data['operator']
            );
        } catch (\Exception $e) {
            Log::error(Carbon::now()->toDateTimeString() . ' 金额记录失败：' . $e->getMessage() . $e->getLine() . $e->getFile());
        }
    }

}
